

package com.hazelcast.test.starter.answer;

import org.mockito.invocation.InvocationOnMock;

/**
 * Default {@link org.mockito.stubbing.Answer} to create a mock for a proxied
 * {@link com.hazelcast.internal.server.FirewallingConnectionManager}.
 */
class FirewallingConnectionManagerAnswer extends AbstractAnswer {

    FirewallingConnectionManagerAnswer(Object delegate) {
        super(delegate);
    }

    @Override
    Object answer(InvocationOnMock invocation, String methodName, Object[] arguments) throws Exception {
        if (methodName.equals("blockNewConnection") || methodName.equals("closeActiveConnection") || methodName.equals("unblock")) {
            return invoke(invocation, arguments);
        } else
            if (arguments.length == 0 && methodName.equals("toString")) {
                return delegate.toString();
            }
        throw new UnsupportedOperationException("Method is not implemented FirewallingConnectionManagerAnswer: " + methodName);
    }
}
